USE [web-vote]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_candidato_eleccion]') AND parent_object_id = OBJECT_ID(N'[dbo].[candidato]'))
ALTER TABLE [dbo].[candidato] DROP CONSTRAINT [FK_candidato_eleccion]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_candidato_grupo_electoral]') AND parent_object_id = OBJECT_ID(N'[dbo].[candidato]'))
ALTER TABLE [dbo].[candidato] DROP CONSTRAINT [FK_candidato_grupo_electoral]
GO

USE [web-vote]
GO

/****** Object:  Table [dbo].[candidato]    Script Date: 10/05/2013 10:45:07 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[candidato]') AND type in (N'U'))
DROP TABLE [dbo].[candidato]
GO

USE [web-vote]
GO

/****** Object:  Table [dbo].[candidato]    Script Date: 10/05/2013 10:45:07 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[candidato](
	[id_candidato] [int] IDENTITY(1,1) NOT NULL,
	[id_grupo_electoral] [int] NOT NULL,
	[id_usuario] [int] NOT NULL,
	[id_eleccion] [int] NOT NULL,
 CONSTRAINT [PK_candidato] PRIMARY KEY CLUSTERED 
(
	[id_candidato] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[candidato]  WITH CHECK ADD  CONSTRAINT [FK_candidato_eleccion] FOREIGN KEY([id_eleccion])
REFERENCES [dbo].[eleccion] ([id_eleccion])
GO

ALTER TABLE [dbo].[candidato] CHECK CONSTRAINT [FK_candidato_eleccion]
GO

ALTER TABLE [dbo].[candidato]  WITH CHECK ADD  CONSTRAINT [FK_candidato_grupo_electoral] FOREIGN KEY([id_grupo_electoral])
REFERENCES [dbo].[grupo_electoral] ([id_grupo_electoral])
GO

ALTER TABLE [dbo].[candidato] CHECK CONSTRAINT [FK_candidato_grupo_electoral]
GO


